package work.chenbo.spring_boot_shiro.common.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author ChenBo
 * @className ResponseObject
 * @date 2019/10/29
 */
@Data
public class ResponseObject implements Serializable {
    private Integer code;
    private String msg;
    private Object data;

    public static ResponseObject getInstances(){
        return new ResponseObject();
    }

    public static ResponseObject success(){
        ResponseObject responseObject = getInstances();
        responseObject.setCode(200);
        responseObject.setMsg("success");
        return responseObject;
    }

    public static ResponseObject success(Object data){
        ResponseObject responseObject = getInstances();
        responseObject.setCode(200);
        responseObject.setMsg("success");
        responseObject.setData(data);
        return responseObject;
    }

    public static ResponseObject fail(Integer code,String msg){
        ResponseObject responseObject = getInstances();
        responseObject.setCode(code);
        responseObject.setMsg(msg);
        return responseObject;
    }

    public static ResponseObject fail(){
        ResponseObject responseObject = getInstances();
        responseObject.setCode(1000);
        responseObject.setMsg("fail");
        return responseObject;
    }
}
